package com.zareal.ymcc.feign;

import com.zareal.ymcc.enums.GlobalErrorCode;
import com.zareal.ymcc.result.JSONResult;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class MediaFeignClientFallbackFactory implements FallbackFactory<MediaFeignClient> {
    @Override
    public MediaFeignClient create(Throwable throwable) {
        log.info("执行根据课程id获取的视频熔断");
        return new MediaFeignClient() {
            @Override
            public JSONResult selectMediaByCourseId(Long courseId) {
                return JSONResult.error("获取视频熔断", GlobalErrorCode.ERROR.getErrorMessage());
            }
        };
    }
}
